//
//  LJYMyTableViewCellTwo.m
//  WWLNetease
//
//  Created by 李锦耀 on 15/12/23.
//  Copyright © 2015年 Echo.Jobs. All rights reserved.
//

#import "LJYMyTableViewCellTwo.h"

@interface LJYMyTableViewCellTwo ()

@property(nonatomic, strong)UIImageView *titleImageOne;
@property(nonatomic, strong)UIImageView *titleImageTwo;
@property(nonatomic, strong)UIImageView *titleImageThree;
@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UILabel *sourceLabel;
@property(nonatomic, strong)UIButton *detailButton;
@property(nonatomic, strong)NSDictionary *attrDict3;

@end

@implementation LJYMyTableViewCellTwo

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        UIImageView *image= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"u=299799948,2184997942&fm=21&gp=0.jpg"]];
        self.backgroundView = image;
        [self creatAction];
    }
    return self;
}

-(void)creatAction
{
    
    self.attrDict3 = @{ NSStrokeWidthAttributeName: @(4),
                        NSStrokeColorAttributeName: [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1],
                        NSFontAttributeName: [UIFont systemFontOfSize:18] };
    
    _titleImageOne = [[UIImageView alloc] init];
    _titleImageOne.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_titleImageOne];
    [_titleImageOne mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(3);
        make.left.mas_equalTo(2);
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.67);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.67);
    }];
    
    _titleImageTwo = [[UIImageView alloc] init];
    _titleImageTwo.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_titleImageTwo];
    [_titleImageTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.titleImageOne);
        make.left.equalTo(self.titleImageOne.mas_right).offset(2);
        make.right.mas_equalTo(self.contentView.mas_right).offset(-2);
        make.height.equalTo(self.titleImageOne.mas_height).multipliedBy(0.47);
    }];
    
    _titleImageThree = [[UIImageView alloc] init];
    _titleImageThree.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_titleImageThree];
    [_titleImageThree mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.titleImageTwo.mas_bottom).offset(2);
        make.left.equalTo(self.titleImageOne.mas_right).offset(2);
        make.right.mas_equalTo(self.contentView.mas_right).offset(-2);
//        make.height.equalTo(self.titleImageOne.mas_height).multipliedBy(0.52);
        make.bottom.equalTo(self.titleImageOne);
    }];
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.backgroundColor = [UIColor clearColor];
    _titleLabel.font = [UIFont boldSystemFontOfSize:16];
    _titleLabel.textColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1];
    _titleLabel.numberOfLines = 0;
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(self.titleImageOne.mas_bottom).offset(5);
        make.height.mas_equalTo(50);
    }];
    
    _sourceLabel = [[UILabel alloc] init];
    _sourceLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_sourceLabel];
    [_sourceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.titleImageOne.mas_left).offset(5);
//        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(5);
        make.bottom.mas_equalTo(self.titleImageOne.mas_bottom).offset(-4);
//        make.right.mas_equalTo(-100);
        make.right.equalTo(self.titleImageOne.mas_right).offset(-5);
        make.height.mas_equalTo(30);
        
    }];
    
    _detailButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:_detailButton];
    _detailButton.backgroundColor = [UIColor clearColor];
//    [_detailButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.mas_equalTo(self.sourceLabel.mas_right).offset(6);
//        make.top.equalTo(self.sourceLabel);
//        make.right.equalTo(self.contentView.mas_right);
//        make.bottom.mas_equalTo(self.contentView).offset(-4);
//    }];
    
}
-(void)setRecommend:(LJYRecommendmodelTwo *)recommend
{
    self.titleLabel.text = recommend.title;
//    self.sourceLabel.text = recommend.source;
    self.sourceLabel.attributedText = [[NSAttributedString alloc] initWithString: recommend.source attributes: self.attrDict3];
    [self.titleImageOne sd_setImageWithURL:[NSURL URLWithString:recommend.img] placeholderImage:[UIImage imageNamed:@"u=1625671141,2113623839&fm=21&gp=0.jpg"]];

    [self.titleImageTwo sd_setImageWithURL:[[recommend.imgnewextra firstObject] objectForKey:@"imgsrc"] placeholderImage:[UIImage imageNamed:@"u=1625671141,2113623839&fm=21&gp=0.jpg"]];
    
    [self.titleImageThree sd_setImageWithURL:[[recommend.imgnewextra lastObject] objectForKey:@"imgsrc"] placeholderImage:[UIImage imageNamed:@"u=1625671141,2113623839&fm=21&gp=0.jpg"]];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
